#ifndef FACEDISCERN_H
#define FACEDISCERN_H

#pragma once

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/face.hpp"
#include "opencv2/face/facerec.hpp"
#include "opencv2/objdetect.hpp"
#include "qrect.h"

#include <QObject>

#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <QVector>
#include <vector>

using namespace std;
using namespace cv;
using namespace cv::face;

#define SafeFree(p) { if ((p)) free(p); (p) = NULL; }
#define SafeArrayDelete(p) { if ((p)) delete [] (p); (p) = NULL; }
#define SafeDelete(p) { if ((p)) delete (p); (p) = NULL; }

#define FACE_BASE_DIR   "/home/root/My_Qt/Face_Recognize/"
#define FACE_CSV        "data/doc/face_csv.txt"
#define FACE_XML        "data/doc/face_xml.xml"
#define FACE_ALT        "data/doc/haarcascade_frontalface_alt.xml"

/*
 *My_Qt
 *----|Face_Recognize
 *------------------|data
 *----------------------|doc
 *----------------------|images
 *------------------|face_rec
 *----|other project
*/

class FaceDiscern : public QObject
{
    Q_OBJECT
public:
    FaceDiscern();
    ~FaceDiscern();

    string base_dir;
    string index_filename;
    string recognizer_filename;
    string face_detector_filename;

    Ptr<LBPHFaceRecognizer> getModel();

    bool face_train(string& filelist_txt);
    bool update_face(vector<Mat>& mats, vector<int>&labels);
    bool face_find(Mat& frame_input, vector<Mat>& testImages);
    vector<int> face_predict(vector<Mat>& testImages);

private:
    Ptr<LBPHFaceRecognizer> model;

};

#endif // FACEDISCERN_H
